import request from '../request.ts'

//查询字典值
export const getDic = async  (key:String) => {
    let r:any = await request({
        url: '/getDict',
        method: 'get',
        data:{
            key:key
        },
        loading: true,
    })
    return r.data
}

//获取列表
export const getDictTypeList = async  (search:Object) => {
    let r:any = await request({
        url: '/system/dict_type/list',
        method: 'get',
        loading: true,
        data:search
    })
    return {
        data:r.data.rows,
        total:r.data.total
    }
}

//新增字典
export const addDict = async  (data:Object) => {
    let r:any = await request({
        url: '/system/dict_type/edit',
        method: 'post',
        loading: true,
        data:data
    })
    return r
}
//修改字典
export const editDict = async  (data:Object) => {
    let r:any = await request({
        url: '/system/dict_type/edit',
        method: 'put',
        loading: true,
        data:data
    })
    return r
}
//删除字典
export const delDict = async  (id:Number) => {
    let r:any = await request({
        url: '/system/dict_type/delete',
        method: 'delete',
        loading: true,
        data:{
            dictId:id
        }
    })
    return r
}

//获得字典值列表
export const getKeywordList = async  (search:Object) => {
    let r:any = await request({
        url: '/system/dict_data/list',
        method: 'get',
        loading: true,
        data:search
    })
    return {
        data:r.data.rows,
        total:r.data.total
    }
}
//新增字典值
export const addKeyword = async  (data:Object) => {
    let r:any = await request({
        url: '/system/dict_data/edit',
        method: 'post',
        loading: true,
        data:data
    })
    return r
}
//修改字典值
export const editKeyword = async  (data:Object) => {
    let r:any = await request({
        url: '/system/dict_data/edit',
        method: 'put',
        loading: true,
        data:data
    })
    return r
}
//删除字典值
export const delKeyword = async  (id:Number) => {
    let r:any = await request({
        url: '/system/dict_data/delete',
        method: 'delete',
        loading: true,
        data:{
            dictCode:id
        }
    })
    return r
}